package com.zmj.controller;

import com.zmj.common.Res;
import com.zmj.entity.Article;
import com.zmj.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    @PostMapping("/create")
    public Res create(@RequestBody Article article){
        Article res = articleService.create(article);
        if (res != null){
            return new Res(1,"增加成功！",article);
        }else {
            return new Res(0,"失败！",null);
        }
    }
    @GetMapping("/get")
    public Res getArticle(){
        List<Article> list = articleService.getArticle();
        if (list != null){
            return new Res(1,"增加成功！",list);
        }else {
            return new Res(0,"???！",null);
        }

    }


}
